package src.main.java.org.generic.genericsMethods;

import src.main.java.org.oop.override.A;
import src.main.java.org.oop.override.B;

import java.util.ArrayList;

public class Test {
    public static void main(String[] args) {
        String java = test("java");
        Dog dog = test(new Dog());

        ArrayList<Car> cars = new ArrayList<>();
        cars.add(new BMW());
        cars.add(new BENZ());
        go(cars);

        ArrayList<BMW> bmws = new ArrayList<>();
        bmws.add(new BMW());
        bmws.add(new BMW());
        go(bmws);  //与ArrayList<Car>无关

        ArrayList<BENZ> benzs = new ArrayList<>();
        benzs.add(new BENZ());
        benzs.add(new BENZ());
        go(benzs);

    }

//限定是Car或Car的子类
   /* public static <T extends Car> void go(ArrayList<T> cars){

    }*/

    public static  void go(ArrayList<? extends Car> cars){

    }
    public static <T> T test(T t){
        return t;
    }
}
